Alibabacloud.com offers a wide variety of articles about postgresql create procedure, easily find your postgresql create procedure information here online.
Reprinted from http://zhenghaoju700.blog.163.com/blog/static/13585951820116782843994/Install a PostgreSQL first (see Supplemental knowledge)Compare Oracle PL/SQLDbms_output.put_line ("This is a log") in PL/SQL; Simple commissioning is possibleOf course our PostgreSQL also has the corresponding function RAISE NOTICE ' This is a log% ', param;% placeholder param replacement ValueRAISE There are other levels d
Create a postgresql Partition Table. Create a postgresql partition table.
In postgresql, there is no partition table creation command. It is created by creating rules such as inherited tables and constraints. The steps are cumbersome and troublesome, and a method is encapsu
PostgreSQL Stored Procedure
What is a Stored Procedure, which is defined by Baidu Encyclopedia: A Stored Procedure (Stored Procedure) is a set of SQL statements in a large database system to complete specific functions, after the first compilation, the stored
PostgreSQL Stored Procedure return dataset instance
Here we use an instance to demonstrate how to return a dataset from a PostgreSQL stored procedure.
1. Prepare the data table first.
// Member_categoryCreate table member_category (id serial, name text, discount_rate real, base_integral integer );Alter table member_cat
Mysql Stored Procedure learning notes-create a simple stored procedure, mysql Stored Procedure
I. Stored Procedure
Stored Procedures (Stored Procedure) are a set of SQL statements for specific functions in large database systems.
Tags: int title color Erb BSP using RET images fromPostgreSQL tables, function names are strictly case-sensitive, so when used without notice that the case of the problem is easy to find the function name error, but in the last two days we found that if the function parameters use a custom data type, this problem also occurs.Problem Description:The following example tests the code: Pwmis. DataProvider.Data.AdoHelper db = Mydb.getdbhelperbyconnectionname ("
Tags: PostgreSQL stored procedure dataset function UbuntuHere is an example that demonstrates how the PostgreSQL stored procedure returns a dataset.1 Prepare the Data sheet firstALTER TABLE member add Onaccount int;alter table member add store_name text;2 Inserting test dataInsert into Member_category (name, discount_r
provide complete procedure.DROP FUNCTION IF EXISTS syncref (); CREATE OR REPLACE FUNCTION syncref () RETURNS void As$body$declare r record;sqlstr Text: = ' SELECT id,regexp_split_to_table (Refids, ', ') as RefId from TableA where "Length" (refids) > 0; '; Begindelete from TableB; For R in EXECUTE sqlstr loopif ("Length" (R.refid) > 0 and R.refid! = ', ') Theninsert into TableB (id,ref_id) VALUES (r.id,c AST (R.refid as BIGINT)); END IF; END LOOP; RET
Here is an example to illustrate how the PostgreSQL stored procedure returns a dataset.
1. Prepare data table First
Copy Code code as follows:
Member_category
CREATE TABLE Member_category (ID serial, name text, Discount_rate real, base_integral integer);
ALTER TABLE Member_category add primary key (ID);
ALTER TABLE member_category Add check
PostgreSql Procedure copy split string to table, postgresqlsplit
In my scenario, there is a table with a field storing data using split string.
Although Hibernate provides org. hibernate. annotations. Type annotations, You can implement org. hibernate. usertype. UserType to convert the result data, but it is not convenient to use.
I replaced this data with a mapping table. Of course, there is no problem w
|| '_result';
END; $$ LANGUAGE plpgsql;2.2 Case 2: Return case without an expressionIf you declare a function to return void, a return statement can be used to exit the function prematurely, but do not write an expression after return. CREATE OR REPLACE FUNCTIONGetreturn (in_col1int)
RETURNSvoid as $$
BEGIN
ifIn_col1> 0 ThenRAISE NOTICE'There is%', In_col1; Else
return; End if;
END; $$ LANGUAGE plpgsql;3. RETURN Next command syntax:RETURN N
In the help of access itself, I saw the create procedure statement. After testing for a long time, I finally found out that the create procedure statement can be used only when the oledb connection is used. ODBC connection does not support this statement, and the create tabl
=Passwordte andState=1Loopreturn Nextuser_list;EndLoop;End; $BODY $ LANGUAGE plpgsql VOLATILE Cost -; There is also a direct select, which is not posted here, after the success of the decision to directly use the SELECT statement on the line, no return value. We need to add a parameter back to the judging situation, so I use the out output here, is also more flexible. The output parameter prefix plus T is because the PSQL version variable I'm using is not conflicting. --output parameter usage
, and if you want to represent% itself in format, you can use a percentage of percent, as shown in the following example:RAISE NOTICE ' calling cs_create_job (%) ', the value of the V_JOB_ID;--V_JOB_ID variable will be replaced by% in format.RAISE EXCEPTION ' inexistent ID---% ', user_id; In simple terms: -- Throw Exception
' you have a problem. The repair! ';
-- use SQLERRM to display error messages.
'(%)', SQLERRM; See the example below: CREATE
Update NBearLite to v1.0.0.6 beta
Fully supports SQL Server, Oracle, MySql, and PostgreSql database Stored Procedure Call code generation (C #/VB. NET) and various parameter types such as input, output, and return.
Sub Query is supported.
Save able/DataRow is supported.
See: http://www.cnblogs.com/teddyma/archive/2007/07/20/825384.html
Introduction
Use nbearlite.querycolumnsgenerator.exe and specify the tar
What is stored procedure, Baidu Encyclopedia is so defined: the stored procedure (Stored Procedure) is in a large database system, a set of SQL statements in order to complete a specific function, stored in the database after the first compilation and re-call do not need to compile again, The user executes it by specifying the name of the stored
What is stored procedure, Baidu Encyclopedia is so defined: the stored procedure (Stored Procedure) is in a large database system , a set of SQL statements in order to complete a specific function, stored in the database after the first compilation and re-call do not need to compile again, The user executes it by specifying the name of the stored
N-more SQL statements, but their own time, but everywhere is the pit ah, ah, ah!!!!!!!!!!!!!!!Want to write a get the latest ID value in the table.On the CodeCREATE TABLEDepartment (IDINT PRIMARY KEY not NULL, D_codeVARCHAR( -), D_nameVARCHAR( -) not NULL, D_parentidINT not NULL DEFAULT 0); --INSERT INTO department values (1, ' 001 ', ' Office ');--INSERT INTO department values (2, ' 002 ', ' Office ', 1);Here is a stored
Fedora
User
To the operation of the database, first transfer to Postgres user
The first time you want to set a password
sudo passwd postgres
Switch to this user
Su-postgres
Database initialization
The first time to do
initdb/var/lib/pgsql/data/
pg_ctl-d/var/lib/pgsql/data-l logfile Start
PS: Built in the home is better, home space generally give a relatively large, I used to encounter PostgreSQL database space is full of problems
Initdb/ho
Label:Here is an example that demonstrates how the PostgreSQL stored procedure returns a dataset.1 Prepare the Data sheet firstMember_categoryCREATE TABLE Member_category (ID serial, name text, Discount_rate real, base_integral integer);ALTER TABLE Member_category add primary key (ID);ALTER TABLE member_category Add check (nameMemberCREATE TABLE member (ID serial, member_num text, name text, category_id int
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.